<template>
  <div>
    <van-tabbar route>
      <van-tabbar-item push to="/home" icon="home-o">首页</van-tabbar-item>
      <!-- <van-tabbar-item replace to="/topic" icon="search">专题</van-tabbar-item> -->
      <van-tabbar-item push to="/category" icon="bag">分类</van-tabbar-item>
      <van-tabbar-item @click="Gotocart" icon="cart-o" :badge="badgeproduct?badgeproduct:''">购物车</van-tabbar-item>
      <van-tabbar-item push to="/mine" icon="friends-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      
    }
  },
  methods: {
    Gotocart(){
     let user=this.$store.getters.user
     if (!user) {
        this.$toast.fail("请登录")
        return
     }else{
       this.$router.push('/cart')
     }
    }
  },
  computed:{
    badgeproduct(){
      return this.$store.getters.cartList.length
    }
  }
};
</script>

<style lang="scss" scoped>
 .van-tabbar{
    z-index: 99999;
 }

</style>